#ifndef DEEPSEEK_CHAT_H
#define DEEPSEEK_CHAT_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>

// 提前声明聊天气泡和按钮类
class Widget_funcA_Smart_chat;
class Button_Cust_Base;

class Deepseek_Chat : public QObject
{
    Q_OBJECT
public:
    explicit Deepseek_Chat(QObject *parent = nullptr);
    void ask(const QString &userInput);

signals:
    void replyReady(const QString &reply);  // AI回复信号
    void error_signals(const QString &message);  // 错误信号

private slots:
    void onReplyFinished(QNetworkReply *reply);  // 处理API返回

private:
    QNetworkAccessManager *manager;  // 网络请求管理器
    QJsonArray messageHistory;  // 聊天历史记录
    const QString apiKey = "sk-598479b8aa8e46c4b7b4afa7de98aa4c";  // 替换为有效API Key
    const QString apiUrl = "https://api.deepseek.com/v1/chat/completions";  // API地址
};
